﻿namespace IOLib
{
    using System;

    public class SSException : Exception
    {
        public Error ErrorId;

        public SSException(Error ErrorId) : this(ErrorId, null)
        {
        }

        public SSException(Error ErrorId, Exception InnerException) : this(ErrorId, InnerException, GetErrorText(ErrorId))
        {
        }

        public SSException(Error ErrorId, Exception InnerException, string Message) : base(Message, InnerException)
        {
            this.ErrorId = ErrorId;
        }

        public static Error GetErrorId(Exception e)
        {
            if (e is SSException)
            {
                return ((SSException) e).ErrorId;
            }
            return Error.CriticalError;
        }

        public static string GetErrorText(Error inc)
        {
            if (inc == Error.NoError)
            {
                return string.Empty;
            }
            return GlobalParams.LanguageErrors[(int) inc];
        }
    }
}

